﻿namespace FSLib

type FilterPiyo() =
    interface IFilter3D with

        member this.FilterName = "Piyo"
        member this.Description = "グレースケール化（平均）"

        member this.Compute mat:byte[,,] =
            let x = - 1 + Array3D.length1 mat 
            let y = - 1 + Array3D.length2 mat 
            let rlt = mat
            for i in 0..x do
                for j in 0..y do
                    let (b,g,r) = MyArray3D.getCell mat i j
                    let ave = (int b + int g + int r)/3
                    MyArray3D.setCell rlt i j (byte ave,byte ave,byte ave)
            rlt
